<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="index.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<!-- <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="favicon.ico" >
    <link rel="Shortcut Icon" href="favicon.ico" /> -->

<!-- <title>主页</title>
    <meta name="keywords" content="耶回收">
    <meta name="description" content="耶回收"> -->

<link href="<%=basePath%>lib/webuploader/0.1.5/webuploader.css"
	rel="stylesheet" type="text/css" />
</head>
<style type="text/css">
.h_css{
   width:100%;
   height:40px;
   background:#f6f6f6;
   font-size:18px;
   line-height:40px;
   margin-top:20px;
}
</style>
<body>

	<!--_表格--开始-->
	<section class="Hui-article-box" style="overflow: auto"> <nav
		class="breadcrumb">
		<i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>
	评估管理 <span class="c-gray en">&gt;</span> 回收商品管理 <span class="c-gray en"></span>
	</nav> <!--     checkBackitemExsit() -->
	<div class="page-container">
		<!-- <div class="h_css">商品品牌的添加<i class="Hui-iconfont">&#xe716;</i></div> -->

			<div class="h_css">商品评估条件的添加<i class="Hui-iconfont">&#xe716;</i></div>
			<div class="form form-horizontal">
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><span
					class="c-red">*</span>商品分类：</label>
				<div class="formControls col-xs-8 col-sm-4">
					<!--<span class="select-box">  -->
					<select class="input-text" name="cid" id="classifyselect" onchange="getassessmentBymid()">
						<c:forEach items="${ classifylist}" var="classify">
							<option value="${classify.cid }">${classify.classifyname}</option>
						</c:forEach>
					</select>
					<!-- </span> -->
				</div>
			</div>
			
			<!--  获取商品评估的下拉菜单的展示属性列表 -->
			<div class="row cl">
			    <label class="form-label col-xs-4 col-sm-2"><span
					class="c-red">*</span>已有分类的评估条件：</label>
				<div class="formControls col-xs-8 col-sm-4">
					<select id="assess" class="input-text">
					<c:forEach items="${assesslist }" var="assess">
					<option value="${assess.assess_id }">${assess.assessname }</option>
					</c:forEach>
					</select>
				</div>
			</div>
			<h3>添加评估条件</h3>
			     <i>温馨提示：请不要重复添加已有评估条件</i><button style="margin-left:20px;" class="btn btn-primary-outline radius" id="assess_view">
						<i class="Hui-iconfont">&#xe725;</i>查看管理
					</button>
				<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><span
					class="c-red">*</span>评估条件名称：</label>
				<div class="formControls col-xs-8 col-sm-4">
					<input type="text" class="input-text" placeholder="输入评估条件" id="assess_text"/>
				</div>
			</div>
			
			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
					<button class="btn btn-primary radius" id="assess_btn">
						<i class="Hui-iconfont">&#xe632;</i>添加评估条件
					</button>
				</div>
			</div>
			</div>
	</div>
	</section>



	<!--/_footer /作为公共模版分离出去-->

	<!--请在下方写此页面业务相关的脚本-->
	<script type="text/javascript"
		src="lib/webuploader/0.1.5/webuploader.min.js"></script>
	<script type="text/javascript">

   //根据 分类查询商品评估条件列表
	function getassessmentBymid() {
			var cid = $("#classifyselect").val();
			$.ajax({
				type : 'POST',
				url : 'getassessmentBymid',// 根据型号查询商品评估条件列表！
				data : {
					"cid" : cid
				},
				dataType : 'json',
				success : function(data) {
					var b = data.assessment;
					$("#assess").empty();
					//$("#modelselect").append("<option value="">请选择品牌</option>");
					for (var i = 0; i < b.length; i++) {
						$("#assess").append(
								"<option value="+b[i].assess_id+">" + b[i].assessname
										+ "</option>");
					}/* else{
						
						layer.msg("暂无数据");
					} */
					
				},
				error : function(data) {
					console.log(data.msg);
				},
			});

		}
	
  //添加评估条件的ajax
	$(function(){
		$("#assess_btn").click(function(){
			var cid =$("#classifyselect").val();
		  var assessname = $("#assess_text").val();
		  if(assessname==null||assessname==""){
			  layer.msg("请填写评估条件",{icon: 2,time:1000});
			 return false;
		  }else{ 
		  $.ajax({
				type :"POST",
				url : "checkAssessExist",//验证添加的评估条件是否已经存在！
				data : {
					"assessname":assessname,
					"cid":cid
				},
				dataType : "json",
				success : function(data) {
					//判断数据库是否存在该分类若存在则不允许添加
					if(data.flag){
						layer.msg("请不要重复添加已有评估条件！",{icon: 2,time:2000});
					}else{
					$.ajax({
							type : "POST",
							url : "addAssessment",
							data : {
								"assessname":assessname,
								"cid":cid
							},
							dataType :"json",
							success : function(data) {
								var b = data.assess;
								$("#assess").empty();
								//$("#modelselect").append("<option value="">请选择品牌</option>");
								for (var i = 0; i < b.length; i++) {
									$("#assess").append(
											"<option value="+b[i].assess_id+">" + b[i].assessname
													+ "</option>");
								}
								
								layer.msg("添加成功",{icon: 1,time:2000});
							},
							error : function(data) {
								layer.msg("添加评估条件 ajax通讯异常");
							},
						});	
				}	 
				},
				error : function(data) {
					layer.msg("验证要添加的评估条件名称存在 --ajax通讯异常");
				}
				
				});
		  
		  }
		});
		
		
		  //查看管理评估属性
		  $("#assess_view").click(function(){
			  var cid = $("#classifyselect").val();
			  var index =layer.open({
				  type: 2,
		          skin:'demo-class',
		          anim:1,
		          shadeClose: true,
		          title:"评估条件属性-信息",
		          area: [650+'px', 400 +'px'],
		          shade:0.3,
		          content:"getasinfo?cid="+cid,
				  end:function(){window.location.href=window.location.href;}
			  }); 
		  }); 
		
		
	});

  
  
  
 
  
	
	
	</script>
</body>
</html>